package cn.doitedu.webserver.controller;

import cn.doitedu.webserver.service.LoginService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LoginController {
    Logger logger = LoggerFactory.getLogger(LoginController.class);

    @Autowired
    LoginService loginService;

    @RequestMapping("/api/login")
    public String login(String account,String password){
        logger.warn("进入了登录controller");
        boolean login = loginService.login(account, password);
        if(!login){
            return "/html/loginfail.html";
        }

        return "/html/success.html";
    }


    @RequestMapping("/api/register")
    public String register(String account,String password,String phoneNbr){
        logger.warn("进入了注册controller");
        boolean res = loginService.register(account, password,phoneNbr);
        if(!res){
            return "/html/loginfail.html";
        }
        return "/html/success.html";
    }
}
